package com.chendx.store.search.mq.listenner;

import com.chendx.store.search.service.SearchService;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

/**
 * Created by chendx on 2022/5/12.
 */
@RabbitListener(queues = "search_sku_add_queue")
@Component
public class SkuAddListenner {

    @Autowired
    private SearchService searchService;

    @RabbitHandler
    public void receiver(String message){
        System.out.println("search receiver page_sku_add");
        if (!StringUtils.isEmpty(message)){
            String[] split = message.split(":");
            String skuId = split[0];
            String spuId = split[1];
            searchService.indexSearch(skuId);
        }
    }
}
